﻿using System;
using System.Threading;
using repliback4.Net.ClientSide;
using System.Text;

namespace testapp2 {
    class Program {
        public static EventWaitHandle wh = new EventWaitHandle( false, EventResetMode.AutoReset );
        static void Main ( string[] args ) {
            Console.OutputEncoding = Encoding.UTF8;
            Console.WindowWidth = 160;

            Client client = new Client( );
            try {
                client.OnConnected += new Client.OnConnectedHandler( client_OnConnected );
                client.Connect( "test.thesebas.net", 80 );
                Console.WriteLine( "waiting for connection" );
                wh.WaitOne( );
                Console.WriteLine( "connected, requesting" );

                client.HttpRequestForContent( );
                Thread.Sleep( 2000 );
                client.HttpRequestForContent( );
                Thread.Sleep( 7000 );
                client.HttpRequestForContent( );

            } catch ( Exception e ) {
                Console.WriteLine( e.Message );
                Console.WriteLine( e.StackTrace );
            }

            Console.ReadKey( );
        }

        static void client_OnConnected ( ) {
            Console.WriteLine( "client_OnConnected fired" );
            wh.Set( );
        }
    }
}
